Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new command to help users migrate launch.json configurations #2450

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Aug 15, 2024

Motivation

Ruby LSP now provides better logging and error messages when the debugger failed to start. And we plan to keep improving the debugging experience in the future.

If users are currently using vscode-rdbg and want to try Ruby LSP, we can help them migrate their launch.json configurations to the format used by Ruby LSP.

Implementation

  1. Add a migrateLaunchConfiguration command
  2. In the command, fetch users' launch configurations and apply the changes needed for the migration

The 2nd commit is to fix the message formatting issue caused by #2957

Example Result

This is from a real-world Rails project:

diff --git a/.vscode/launch.json b/.vscode/launch.json
index cc686cd1069..bd05d0d7c60 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -6,58 +6,47 @@
   "configurations": [
     {
       "name": "Attach",
-      "type": "rdbg",
+      "type": "ruby_lsp",
       "request": "attach"
     },
     {
       "name": "Rails Server",
-      "type": "rdbg",
-      "cwd": "${workspaceRoot}",
-      "useBundler": true,
+      "type": "ruby_lsp",
       "request": "launch",
       "env": {
         "DISABLE_SPRING": "1"
       },
-      "command": "${workspaceRoot}/bin/rails",
-      "script": "server",
-      "args": [],
-      "askParameters": false
+      "program": "bin/rails server"
     },
     {
       "name": "Minitest - current line",
-      "type": "rdbg",
-      "cwd": "${workspaceRoot}",
-      "useBundler": true,
+      "type": "ruby_lsp",
       "request": "launch",
       "env": {
         "DISABLE_SPRING": "1"
       },
-      "command": "${workspaceRoot}/bin/rails",
-      "script": "test",
-      "args": ["${file}:${lineNumber}"],
-      "askParameters": false
+      "program": "bin/rails test ${file}:${lineNumber}"
     },
     {
       "name": "Minitest - current file",
-      "type": "rdbg",
-      "cwd": "${workspaceRoot}",
-      "useBundler": true,
+      "type": "ruby_lsp",
       "request": "launch",
       "env": {
         "DISABLE_SPRING": "1"
       },
-      "command": "${workspaceRoot}/bin/rails",
-      "script": "test",
-      "args": ["${file}"],
-      "askParameters": false
+      "program": "bin/rails test ${file}"
     },

And every action works after the migration.

Automated Tests

No test

Manual Tests

  1. Find an application that uses rdbg in its launch.json
  2. Run the new Migrate launch.json configurations from rdbg to ruby_lsp command through VS Code's command palette
  3. Verify that the updated entries still function the same

@st0012 st0012 added enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes labels Aug 15, 2024
@st0012 st0012 self-assigned this Aug 15, 2024
@st0012 st0012 closed this Oct 7, 2024
@st0012 st0012 reopened this Dec 5, 2024
@st0012 st0012 force-pushed the command-to-migrate-launch-json branch from 7b8ff80 to f8fd63c Compare December 5, 2024 20:56
@st0012 st0012 marked this pull request as ready for review December 5, 2024 21:18
@st0012 st0012 requested a review from a team as a code owner December 5, 2024 21:18
},
{
"command": "rubyLsp.migrateLaunchConfiguration",
"title": "Migrate launch.json configurations from rdbg to ruby_lsp",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"title": "Migrate launch.json configurations from rdbg to ruby_lsp",
"title": "Migrate debug launch.json configurations from rdbg to ruby_lsp",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to add debug before it as there's no other types of launch.json.

vscode/src/debugger.ts Outdated Show resolved Hide resolved
vscode/src/debugger.ts Outdated Show resolved Hide resolved
vscode/src/rubyLsp.ts Outdated Show resolved Hide resolved
Ruby LSP now provides better logging and error messages when the debugger
failed to start. And we plan to keep improving the debugging experience
in the future.

If users are currently using vscode-rdbg and want to try Ruby LSP, we can
help them migrate their launch.json configurations to the format used by
Ruby LSP.
@st0012 st0012 force-pushed the command-to-migrate-launch-json branch from 93e785c to a407d77 Compare December 18, 2024 21:34
@st0012 st0012 enabled auto-merge (squash) December 18, 2024 21:37
@st0012 st0012 disabled auto-merge December 18, 2024 22:08
@st0012 st0012 merged commit b005fbc into main Dec 18, 2024
39 checks passed
@st0012 st0012 deleted the command-to-migrate-launch-json branch December 18, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants